home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / utility / utilcli / getinfo.lha / GetAvailMem.c < prev    next >
C/C++ Source or Header  |  1995-09-28  |  1KB  |  49 lines

  1. /* Program: GetAvailMem [CHIP|FAST|ALL]
  2.    Desc: Program that gets available memory and returns the
  3.    result in a global env. variable.
  4.    Author: P Hutchison 3/12/93
  5.    Modifications:
  6.    1. Use Proto headers (25/6/95)
  7.    2. Use PutStr() instead of printf() and improve prototyping (28/9/95)
  8. */
  9.  
  10. #include <proto/exec.h>
  11. #include <proto/dos.h>
  12. #include <exec/memory.h>
  13. #include <exec/types.h>
  14. #include <dos/dos.h>
  15. #include <dos/var.h>
  16. #include <string.h>
  17.  
  18. main(int argc, char *argv[])
  19. {
  20.    struct DOSBase *DOSBase;
  21.    ULONG avail;
  22.    UBYTE name[7];
  23.    UBYTE buf[10];
  24.    
  25.    strcpy(name, "Memory");
  26.    buf[0] = (char)NULL;
  27.    
  28.    if (DOSBase = (struct DOSBase *)OpenLibrary("dos.library",36L))
  29.    {
  30.     avail = 0;  
  31.     if (argc > 1) /* NB: Command name counts as 1 also! */
  32.     {
  33.       if (stricmp(argv[1], "CHIP") == 0)     /* Get amount of memory */
  34.             avail = AvailMem(MEMF_CHIP);
  35.       if (stricmp(argv[1], "FAST") == 0) 
  36.             avail = AvailMem(MEMF_FAST);
  37.       if (stricmp(argv[1], "ALL") == 0) 
  38.             avail = AvailMem(MEMF_ANY);
  39.    
  40.       stcl_d(buf, avail);                /* Convert value to ASCII */
  41.  
  42.       SetVar(name, buf, -1, GVF_GLOBAL_ONLY); /* Set env. variable */
  43.     } else
  44.       PutStr("Format: GetAvailMem [CHIP|FAST|ALL]\n"); 
  45.     CloseLibrary((struct Library *)DOSBase);
  46.    }
  47. }
  48.       
  49.